rm(list = ls())
setwd("/Users/John/Dropbox/")

# --- Load Required Packages --
library(tidyverse)

# --- Load data ---
data <- read_csv("JOP_Replication_Materials/appendix/data/strategic_industry_list.csv")

# --- Create LaTeX table content ---
latex_table <- paste0(
  "\\singlespacing\n",
  "{\\fontsize{8}{10}\\selectfont\n",
  "\\begin{longtable}{|p{1.5cm}|p{10.5cm}|p{3.5cm}|}\n",
  "\\caption{ISIC Industry Classification and Sector} \\label{tab:isic-industry} \\\n",
  "\\hline\n",
  "\\textbf{ISIC} & \\textbf{Industry} & \\textbf{Sector} \\\\\n",
  "\\hline\n",
  "\\endfirsthead\n",
  "\n",
  "\\hline\n",
  "\\textbf{ISIC} & \\textbf{Industry} & \\textbf{Sector} \\\\\n",
  "\\hline\n",
  "\\endhead\n",
  "\n",
  "\\hline\n",
  "\\multicolumn{3}{r}{\\textit{Continued on next page}} \\\n",
  "\\endfoot\n",
  "\n",
  "\\hline\n",
  "\\endlastfoot\n"
)

# --- Add data rows (Replace with the actual data) ---
for(i in 1:nrow(data)) {
  latex_table <- paste0(latex_table, 
                        data$ISIC[i], " & ",
                        data$Industry[i], " & ",
                        data$Sector[i], " \\\\\n")
}

# --- Close LaTeX table ---
latex_table <- paste0(latex_table, "\\end{longtable}\n", "}\n")

# --- Define full path for LaTeX file output ---
tex_file_path <- "JOP_Replication_Materials/appendix/output/B_table_1.tex"

# --- Save LaTeX table to file ---
writeLines(latex_table, tex_file_path)




